<?php if(!defined('OCTOMS')){header('HTTP/1.1 403');die('{"error":"forbidden"}');}
/*
 * @package       OctoMS
 * @subpackage    DesignJotter
 * @link          http://designjotter.com
 * @copyright     Copyright 2012, Valentino-Jivko Radosavlevici
 * @license       GPL v3.0 (http://www.gnu.org/licenses/gpl-3.0.txt)
 * 
 * Redistributions of files must retain the above copyright notice.
 * 
 * @since         OctoMS 0.0.1, WP.OctoMS 2.0.1
 */
	
	/*
	 * Dispatch calls from the index.php file
	 * 
	 * @package OctoMS.com
	 * @subpackage DesignJotter
	 * @link http://designjotter.com
	 * @license       GPL v3.0 (http://www.gnu.org/licenses/gpl-3.0.txt)
	 * @version 1.0
	 * 
	 * @author Valentino-Jivko Radosavlevici
	 */
	class ship extends octoms
	{
		
		/**
		 * Constructor
		 * 
		 * @author Valentino-Jivko Radosavlevici
		 */
		function __construct()
		{
			/**
			 * CORE
			 */
			// Load the view core library
			$this->_('view');

			// Load the input core library
			$this->_('input');
			
			// Load the encrypt helper
			$this->_('encrypt',OMS_CH);
			
			// Load the recursion helper
			$this->_('recursion',OMS_CH);
			
			// Load the html helper
			$this->_('html',OMS_CH);

			/**
			 * App-specific
			 */
			// Load the template library
			$this->_('template',OMS_L);
			
			// Load the settings library
			$this->_('settings',OMS_L);
			
			/**
			 * And load the model
			 */
			$this->_('ship',OMS_M,'model');
			
		}// end function __construct()()
		
		/**
		 * Check set theme options
		 * 
		 * @example 
		 * 
		 * @param 
		 * @return 
		 * 
		 * @author Valentino-Jivko Radosavlevici
		 */
		function _check_theme_options()
		{
			// TODO Verify the front page settings (static or posts)
			
		}// end function _check_theme_options()
		
		/**
		 * Dispatch the request from the index.php file
		 * 
		 * @author Valentino-Jivko Radosavlevici
		 */
		function dispatch()
		{
			// Check theme options
			$this->_check_theme_options();
			
			// Static front page
			if( (is_front_page() && WP_FRONT_PAGE == 'posts') || (!is_front_page() && !is_single() && !is_page()))
			{
				$this->page_list();
			}
			else 
			{
				$this->page_single();
			}
			
		}// end function test()
		
		/**
		 * Static front page
		 * 
		 * @author Valentino-Jivko Radosavlevici
		 */
		function page_list()
		{
			$this->view->display(
				'list-chromium',
				array(
					'data' => $this->model->list_chromium()
				)
			);
			
		}// end function page_list()
		
		/**
		 * Single page display
		 * 
		 * @author Valentino-Jivko Radosavlevici
		 */
		function page_single()
		{
			// Do not show the admin bar in the simplified layout
			if (@isset($_SESSION) && isset($_SESSION['__flash__']['simplified']))
			{
				add_filter('show_admin_bar', '__return_false');  
			}
			
			// Not a simplified layout?
			$this->_('session')->start();
			if(!(isset($_SESSION) && isset($_SESSION['__flash__']['simplified'])))
			{
				// Load the JS
				$this->template
					->scriptroot()
					->js('wp-octoms')
					->scriptroot('_content')
					->css('chromium')
					->js('chromium');
			}
				
			// Load a single chromium page
			$this->view->display('single-chromium');
			
		}// end function page_single()
		
	}// end class ship
	
	
/* End Of File <ship.inc> */